# -*- coding: utf-8 -*-
import numpy as np

a = np.array([[1,2,3],[4,5,6]])

print a[1,2]
index = (1,2)
print a[index]
print a[0:2,1]
print a[:,[0,2]] #取第0和2列
print a[1]
print a[...,1]

for row in a:
    print row
for element in a.flat:
    print element

b = a>4
a[b] = 0
print a

a.shape = 3,2 #修改a的形状,总元素数不变
print a
a.shape = 2,-1 #不指定使用-1

